/*引入nodejs的events事件模块，并通过实例化EventEmitter类绑定和监听事件*/
var events=require('events');

var eventsEmitter=new events.EventEmitter();

var openConnect=function(){
  console.log('打开链接!');
  eventsEmitter.on('getDate',getDate);
  eventsEmitter.emit('getDate');
}
var getDate=function(){
  console.log('获取数据');
    eventsEmitter.on('closeConnect',closeConnect);
  eventsEmitter.emit('closeConnect');
}
var closeConnect=function(){
    console.log('关闭连接！');

}
eventsEmitter.on('openConnect',openConnect);


eventsEmitter.emit('openConnect');
console.log('程序结束！');
